#ifndef CURVA_H
#define CURVA_H

#include <QtXml>
#include <QGraphicsScene>
#include <QGraphicsItem>
#include <QVector>
#include <QPoint>

typedef enum {
	CurveMode,
	StepMode,
	ControlMode,
	FechoConvexo
} RenderMode;

class Curva
{
protected:
	//QGraphicsScene &myScene;



	QVector<QGraphicsItem*> _myPlots;


	QColor _plotColor;

	QColor readColor(QDomElement e);
	QPointF readPoint(QDomElement e);

	int MAX_STEPS;

public:

	QVector<QPointF> _points;

	//Curva(QGraphicsScene &s);
	Curva (void);
	virtual ~Curva() { }

	inline int& max_steps (void) {return this->MAX_STEPS;}

	QColor getColor() { return _plotColor; }
	void setColor(QColor c) { _plotColor = c; }

	virtual void read(QDomElement node) = 0;
	virtual QDomElement save(QDomDocument doc) = 0;

	virtual void addPoint (QPointF p) = 0;
	virtual int removePoint (QPointF* p) = 0;

	virtual void clear (QGraphicsScene &s) = 0;
	virtual void plot(QGraphicsScene &s, QPen& p, RenderMode renderMode) = 0;
	virtual bool validate() = 0;
	virtual bool minimumValidate() = 0;

	virtual QImage draw() = 0;

	virtual QPointF* selectPoint (QPointF& p, const double precision) = 0;
};

#endif // CURVA_H
